package br.com.nooclix.salon.controller;

import java.util.List;

import br.com.nooclix.salon.application.PersonApplication;
import br.com.nooclix.salon.controller.util.ResponseData;
import br.com.nooclix.salon.domain.person.State;
import br.com.nooclix.salon.infrastructure.util.ApplicationContextRegister;

public class PersonController {

	private PersonApplication personApplication = ApplicationContextRegister
			.getBean("personApplication", PersonApplication.class);

	public ResponseData listState() {
		ResponseData responseData = new ResponseData();

		try {
			
			List<State> l = personApplication.listState();
			responseData.setItems(l);
			responseData.setStatus(ResponseData.OK);
		} catch (Exception e) {
			e.printStackTrace();
			responseData.setMessage(e.getMessage());
			responseData.setStatus(ResponseData.FAILED);
		}

		return responseData;

	}
	
	public ResponseData findCitiesByState(State state) {
		ResponseData responseData = new ResponseData();

		try {
			responseData.setItems(personApplication.findCitiesByState(state));
			responseData.setStatus(ResponseData.OK);
		} catch (Exception e) {
			e.printStackTrace();
			responseData.setMessage(e.getMessage());
			responseData.setStatus(ResponseData.FAILED);
		}

		return responseData;

	}

}
